/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import pojo.NguoiDung;
import util.HibernateUtil;

/**
 *
 * @author LaiHuynh
 */
public class NguoiDungDAO {
    public static List<NguoiDung> dangNhap(String taiKhoan, String matKhau) {
        List<NguoiDung> nd = null; 
        Session session = HibernateUtil.getSessionFactory().openSession();
        try { 
            String hql = "select nd from NguoiDung nd where nd.taiKhoan =:taiKhoan and nd.matKhau =:matKhau";
            org.hibernate.Query query = session.createQuery(hql); 
            query.setString("taiKhoan", taiKhoan);
            query.setString("matKhau", matKhau);
            nd = query.list(); 
        } catch (HibernateException ex) { 
            //Log the exception 
            System.err.println(ex); 
        } finally { 
            session.close(); 
        } 
        return nd;
    }
}
